package businesslogic;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;

import org.xml.sax.SAXException;

import com.alchemyapi.api.AlchemyAPI;
import com.alchemyapi.api.AlchemyAPI_NamedEntityParams;

import crawler.BasicCrawlController;
import db.ManualPoolingDriver;
/*
 * GSAT (General Sentiment Analysis Tool) is a tool which provides real-time sentiment analysis
 * in a simple and easy to interpret graphical representation.
 * 
 */

public class GSAT {

	public static HashMap<String, List<EntityInfo> > entityDataMap;
	
	public static AlchemyAPI alchemyObj;
	public static AlchemyAPI_NamedEntityParams entityParams;
	
	public static ManualPoolingDriver db;
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException, SAXException,
			ParserConfigurationException, XPathExpressionException {

		/* 
		 * Flow description:
		 * 1) Get a set of web site addresses and a set of constraints and return relevant pages.
		 * 2) Analyze the pages and retrieve relevant information.
		 * 3) Process the information and display it to the user. 
		 *  
		 */
		
		// Create an AlchemyAPI object.
		alchemyObj = AlchemyAPI.GetInstanceFromFile("testdir/api_key.txt");

		//Create and configure parameters for the call
		entityParams = new AlchemyAPI_NamedEntityParams();
		entityParams.setDisambiguate(false);
		entityParams.setSentiment(true);
		entityParams.setSourceText("cleaned");

		//initialize the database  
		ManualPoolingDriver.initDB();
		
		try {
			BasicCrawlController.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		//close the database 
		ManualPoolingDriver.closeDB();
		
	}
}
